#ifndef VSANIMBASEFUNCTION_H
#define VSANIMBASEFUNCTION_H
#include "VSController.h"
#include "VSAnimTree.h"
#include "VSPutNode.h"
namespace VSEngine2
{	
	class VSStream;
	class VSGRAPHIC_API VSAnimBaseFunction : public VSController
	{
		//RTTI
		DECLARE_RTTI;
	public:
		friend class VSAnimTree;
		virtual ~VSAnimBaseFunction() = 0;
		VSAnimBaseFunction(const VSUsedName & ShowName,VSAnimTree * pAnimTree);
		virtual bool UpdateEx(double dAppTime);
		virtual void ClearFlag();
	protected:
		VSAnimBaseFunction();
	protected:
		VSArray<VSInputNode *> m_pInput;
		VSArray<VSOutputNode *> m_pOutput;
		VSAnimTree * m_pOwner;
		VSUsedName m_ShowName;

		bool m_bIsVisited;

		inline void SetOwner(VSAnimTree * pOwner)
		{
			VSMAC_ASSERT(pOwner);
			m_pOwner = pOwner;
		}

		const VSSkelectonMeshNode * GetSkelectonMeshNode()const;

		void AddAllPutNodeTo(VSArray<VSPutNode *>& LinkArray);
		bool Link(const VSArray<VSPutNode *>& OldLink,const VSArray<VSPutNode *>& NewLink);
	public:

		virtual unsigned int DiskUse()const;

		virtual bool Save(VSStream & rStream,unsigned int &iSaveUse)const;
		virtual bool Load(VSStream & rStream,unsigned int &iSaveUse);
		virtual bool Link(VSStream & rStream);

		virtual bool Register(VSStream & rStream)const;
	public:
		virtual bool Clone(const VSObject *pObject,unsigned int uiType);

		VSInputNode * GetInputNode(unsigned int uiNodeID)const;
		VSInputNode * GetInputNode(const VSString & NodeName)const;

		VSOutputNode * GetOutputNode(unsigned int uiNodeID)const;
		VSOutputNode * GetOutputNode(const VSString & NodeName)const;

		inline const VSUsedName & GetShowName()const
		{
			return m_ShowName;
		}

	};
	typedef VSPointer<VSAnimBaseFunction> VSAnimBaseFunctionPtr;
}
#endif